
/*    'use strict';*/
    var app = angular.module('app',['ng','ngRoute','ui.bootstrap']);

   /* app.config(function ($stateProvider, $urlRouterProvider) {
            $stateProvider
                .state('home', {
                    url: '',
                    views: {
                        '': {
                            templateUrl: 'tpl/home.html',
                            controller: 'mainCtr',
                        }
                    }
                })
                .state('home.con', {
                    url: '/main',
                    views:{
                        'home-con':{
                               templateUrl:'tpl/components/content.html',
                                    }
                         }
                })
                .state('detail', {
                    url: '/detail',
                    views: {
                        '': {
                            templateUrl: 'tpl/components/detailsAll.html',
                            controller: 'detailCtrl'
                        }
                    },
                    params:{
                        "fildId":null
                    }
                })
            $urlRouterProvider.otherwise('');
        });*/
   // 路由
    app.config(function ($routeProvider) {
        $routeProvider
            .when('/home',{
                templateUrl:'tpl/home.html',
                controller:'homeCtrl'
            })
            .when('/home/:coluId',{
                templateUrl:'tpl/home.html',
                controller:'homeCtrl'

            })
            // 文章详情
            .when('/detail',{
                templateUrl:'tpl/components/detail.html',
                controller:'detailCtrl',
                cache:false
            })
            .when('/detail/:fileId',{
                templateUrl:'tpl/components/detail.html',
                controller:'detailCtrl',
                cache:false
            })
            // 组图详情
            .when('/detailPicture',{
                templateUrl:'tpl/components/multipuDetail.html',
                controller:'detailCtrl'
            })
            .when('/detailPicture/:fileId',{
                templateUrl:'tpl/components/multipuDetail.html',
                controller:'detailCtrl'
            })
            // 活动进行中详情
            .when('/actIng',{
                templateUrl:'tpl/components/detailActCtrl.html',
                controller:'detailActCtr',
                cache:false
            })
            .when('/actIng/:fileId',{
                templateUrl:'tpl/components/detailActCtrl.html',
                controller:'detailActCtr',
                cache:false
            })
            // 活动未开始已结束详情
            .when('/actNoSt',{
                templateUrl:'tpl/components/actNoStart.html',
                controller:'detailActCtr',
                cache:false
            })
            .when('/actNoSt/:fileId',{
                templateUrl:'tpl/components/actNoStart.html',
                controller:'detailActCtr',
                cache:false
            })
            //直播
            .when('/liveDetail',{
                templateUrl:'tpl/components/detailLiveCtrl.html',
                controller:'detailLiveCtrl'
            })
            .when('/liveDetail/:linkID',{
                templateUrl:'tpl/components/detailLiveCtrl.html',
                controller:'detailLiveCtrl'
            })
            .when('/liveDetail/:fileId/:linkID',{
                templateUrl:'tpl/components/detailLiveCtrl.html',
                controller:'detailLiveCtrl'
            })
            //专题
            .when('/speci',{
                templateUrl:'tpl/components/speci.html',
                controller:'specCtrl'
            })
            .when('/speci/:fileId/:linkID',{
                templateUrl:'tpl/components/speci.html',
                controller:'specCtrl'
            })
            //专题2
            .when('/detailSpec',{
                templateUrl:'tpl/components/detailSpec.html',
                controller:'detailSpecCtr'
            })
            .when('/detailSpec/:columnId',{
                templateUrl:'tpl/components/detailSpec.html',
                controller:'detailSpecCtr'
            })
            //视频
            .when('/detailVedio',{
                templateUrl:'tpl/components/detaVed.html',
                controller:'detailVedioCtr'
            })
            .when('/detailVedio/:fileId',{
                templateUrl:'tpl/components/detaVed.html',
                controller:'detailVedioCtr'
            })
            //首页推荐
            .when('/moreModule',{
                templateUrl:'tpl/components/moreModule.html',
                controller:'moreModuleCtr'
            })
            .when('/moreModule/:moduleId',{
                templateUrl:'tpl/components/moreModule.html',
                controller:'moreModuleCtr'
            })
            //全局搜索
            .when('/search',{
                templateUrl:'tpl/components/searchContents.html',
                controller:'moreModuleCtr'
            })
            .otherwise({redirectTo:'/home'});
    });

app.controller('parentCtrl',
    ['$scope','$location','$http','$rootScope','$routeParams','$sce','$window','$interval', function ($scope,$location,$http,$rootScope,$routeParams,$sce,$window,$interval) {
       //loading提示
        $("#globalLoading").css({opacity:'1'});

        $scope.sceControl = $sce.trustAsResourceUrl;
        $scope.jump = function (arg) {
            $("body").animate({scrollTop: 0}, 300);
            $location.path(arg,{}, { reload: true });
        };

        //h5稿件跳转
        $scope.h5Jump= function (argUrl) {
            window.open(argUrl,'_blank')
        };

        //评论点击跳转到指定位置
        $scope.commentJump=function(){
            if($scope.siteConfigAuditType==2||$scope.currentDiscussClosed==1){
                alert()
                return
            }else if($scope.siteConfigAuditType!=2&&$scope.currentDiscussClosed!=1){
                var scrollDistance=$(".commet_count").offset().top;
                $("body").animate({scrollTop:scrollDistance}, 300);
            }

        };

        //回到顶部
        $(".baToTop").hide();
        console.log($(".baToTop"))
        $(window).on("scroll", function(){
            if($(window).scrollTop() >0){
                $(".baToTop").show();

            }else{
                $(".baToTop").hide();
            }
        });
        $scope.goBackTop=function () {
            $("body").animate({scrollTop: 0}, 300);
        };

        //文章详情刷新
        $scope.refreshDetailAll=function() {
            location.reload(true)
        };

        //获取全局配置信息
        $scope.getCommentInfo=function(){

            $http.jsonp(commInfo+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("全局评论信息");
                console.log(data);
                $scope.siteConfig=data.siteConfig.discuss;
                //评论框提示语
                //defaultHint=$scope.siteConfig.defaultHint;
                //siteConfig.defaultHint=$scope.siteConfig.defaultHint;
                ////评论框标题提示语
                //siteConfig.defaultTitle=$scope.siteConfig.defaultTitle;
                ////官方评论用户名
                //siteConfig.defaultName=$scope.siteConfig.defaultName;
                //$rootScope.siteConfigDefaultName=$scope.siteConfig.defaultName;
                ////官方评论头像
                //siteConfig.defaultIcon=$scope.siteConfig.defaultIcon;
                //$rootScope.siteConfigDefaultIcon=$scope.siteConfig.defaultIcon;
                //全局评论是否关闭=2关闭
                siteConfig.auditType=$scope.siteConfig.auditType;
                //全局评论颜色
                siteConfig.styleColor=$scope.siteConfig.styleColor;
                console.log("评论颜色");
                console.log(siteConfig.styleColor);
                //全局是否允许上传评论图片
                siteConfig.showPic=$scope.siteConfig.showPic;
                //是否允许评论时上传图片false和true
                siteConfig.showPic=$scope.siteConfig.showPic;

            }).error(function(data,header,config,status){

            });

        };
        $scope.getCommentInfo();


        // 获取导航cache:true
        $scope.getNavCou=function(){
            $http.jsonp(navUrl+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                $scope.navData=data;
                navArr=$scope.navData.columns;

                if(loadNavColu){

                    $scope.chanNav(loadNavColu);

                }else{
                    $scope.chanNav(firstPageColumns);
                }

            }).error(function(data,header,config,status){
            });
        };
        $scope.getNavCou();


        //用户是否已登录
        $interval(function () {
            $scope.uid_fouNder= doGetCookie('uid_fouNder');
            uid_fouNder=doGetCookie('uid_fouNder');
            $scope.username_fouNder= doGetCookie('username_fouNder');
            username_fouNder=doGetCookie('username_fouNder');
            if(!$scope.uid_fouNder){
                console.log("未登录");
            }else{
                console.log("用户已经登录"+$scope.uid_fouNder);

            }
        },3000);

        // 点击导航更新视图根据点击传入columId号
        bannerCount=0;
        // 轮播图个数
        $scope.chanNav=function (coluId) {

            //记录id方便加载更多使用
            $scope.currentPageId=coluId;
            //测试
            currentPageId=coluId;
            console.log("当前id号");
            console.log($scope.currentPageId);
            // var navArr=navDataObj.columns;
            console.log("nav columns");
            console.log(navArr);
            var navIndex=lightIndex;

            for(var i=0;i<navArr.length;i++){
                if(coluId==navArr[i].columnId){
                    navIndex=i;
                    lightIndex=navIndex;
                    break;
                }

            }



            $(".homeNavTextUl li").eq(navIndex).siblings().css({color:'#ffffff',fontSize:'0.16rem'});
            $(".homeNavTextUl li").each(function (index,element) {
                $(element).css("background","#000000");
            });
            $("#homeNavChannelTextUl li").each(function (index,element) {
                $(element).css("background","#ffffff");
                $(element).find('a').css({color:"#000000",fontSize:'0.18rem'});
            });
            $(".homeNavTextUl li").eq(navIndex).css({color:'#000000',fontSize:'0.18rem',background:"#fc9105"});
            $("#homeNavChannelTextUl li").eq(lightIndex).css({background:"#fc9105"});
            $("#homeNavChannelTextUl li").eq(lightIndex).find('a').css({color:"#ffffff",fontSize:'0.18rem'});



            //轮播js
            $scope.myInterval = 200000000;
            $scope.noWrapSlides = false;
            $scope.active = 0;


            //判断是否有轮播图看topCount,决定是否隐藏banner
            $http.jsonp(navUrl+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                $scope.columDataAll=data;
                var datlist=$scope.columDataAll.columns;
                for(var i=0;i<datlist.length;i++){
                    if(datlist[i].columnId==coluId){
                        //根据columnStyle判断加载哪种模板
                        $scope.columnStyle=datlist[i].columnStyle
                        console.log("当前对象")
                        console.log(datlist[i])
                        if(!datlist[i].topCount){
                            $scope.topCountShow=false;
                        }else if(datlist[i].topCount){
                            // 轮播图个数
                            // $scope.bannerCount=datlist[i].topCount;
                            bannerCount=datlist[i].topCount;
                            console.log("轮播个数")
                            console.log(bannerCount)
                            // 含有轮播图处理,只从前20条拿取还是所有数据中判断？？目前是前20条，如果是所有，下面链接换成所有数据请求链接
                            $http.jsonp(articalDataUrl+'columnId='+coluId+'&lastFileId=0&page=0&version=0&jsoncallback=JSON_CALLBACK'
                            ).success(function(datas,header,config,status) {
                                // 存储banner的相关信息
                                $scope.bannerObj = [];
                                $scope.bannerImg = [];
                                var data1=datas.list;

                                var counNum = 0;
                                for (var j = 0; j < data1.length; j++) {
                                    if (counNum<bannerCount) { //轮播个数

                                        if (data1[j].isBigPic == 0) { //先取小图
                                            if (data1[j].picSmall) {
                                                $scope.bannerObj.push(data1[j]);
                                                $scope.bannerImg.push({img:data1[j].picSmall,title:data1[j].title,fileId:data1[j].fileId,articleType:data1[j].articleType,linkID:data1[j].linkID,attAbstract:data1[j].attAbstract});
                                                counNum++;
                                            } else if (data1[j].picMiddle) {
                                                $scope.bannerObj.push(data1[j]);
                                                $scope.bannerImg.push({img:data1[j].picMiddle,title:data1[j].title,fileId:data1[j].fileId,articleType:data1[j].articleType,linkID:data1[j].linkID,attAbstract:data1[j].attAbstract});
                                                counNum++;
                                            } else if (data1[j].picBig) {
                                                $scope.bannerObj.push(data1[j]);
                                                $scope.bannerImg.push({img:data1[j].picBig,title:data1[j].title,fileId:data1[j].fileId,articleType:data1[j].articleType,linkID:data1[j].linkID,attAbstract:data1[j].attAbstract});
                                                counNum++;
                                            }
                                        } else if (data1[j].isBigPic == 1) {//先中图
                                            if (data1[j].picMiddle) {
                                                $scope.bannerObj.push(data1[j]);
                                                $scope.bannerImg.push({img:data1[j].picMiddle,title:data1[j].title,fileId:data1[j].fileId,articleType:data1[j].articleType,linkID:data1[j].linkID,attAbstract:data1[j].attAbstract});
                                                counNum++;
                                            } else if (data1[j].picBig) {
                                                $scope.bannerObj.push(data1[j]);
                                                $scope.bannerImg.push({img:data1[j].picBig,title:data1[j].title,fileId:data1[j].fileId,articleType:data1[j].articleType,linkID:data1[j].linkID,attAbstract:data1[j].attAbstract});
                                                counNum++;
                                            } else if (data1[j].picSmall) {
                                                $scope.bannerObj.push(data1[j]);
                                                $scope.bannerImg.push({img:data1[j].picSmall,title:data1[j].title,fileId:data1[j].fileId,articleType:data1[j].articleType,linkID:data1[j].linkID,attAbstract:data1[j].attAbstract});
                                                counNum++;
                                            }
                                        }
                                    }
                                }
                                $scope.topCountShow = true;
                                if (!$scope.bannerImg[0]) {
                                    $scope.topCountShow = false;
                                }

                                console.log("图片个数")
                                console.log($scope.bannerImg)
                            }).error(function(data1,header,config,status){
                            });
                        }
                    }
                }

                //实现跳转，获取稿件数据,需要先去除轮播图含有的对象，如果直播活动也放在里面？也要切除轮播图中的数据columnId='+coluId +'&lastFileId=0&count=20&rowNumber=0&version=0&jsoncallback=JSON_CALLBACK
                $http.jsonp(articalDataUrl+'columnId='+coluId +'&page=0&lastFileId=0&jsoncallback=JSON_CALLBACK'
                ).success(function (data, header, config, status) {
                    // 插入模块
                    $scope.modules=data.modules;
                    modules=data.modules;
                    console.log("module");
                    console.log($scope.modules);
                    var parentMudulesObj=$scope.modules;

                    // 实际模块个数，决定滑块个数,决定是否显示
                    $scope.infaceModules=[];
                    //判断实际个数，只要type=0的普通类型稿件
                    for(var n=0;n<parentMudulesObj.length;n++){
                        if(parentMudulesObj[n].type==0){
                            $scope.infaceModules.push(parentMudulesObj[n]);
                        }
                    }

                    //根据moduleID关联拿取数据
                    //创建最终返回数据对象数据

                    $scope.childGetMouds=[];
                    for(var p=0;p<$scope.infaceModules.length;p++){
                        (function(p){
                            $scope.childGetMouds[p]=[];
                            console.log($scope.infaceModules[p].moduleID);
                            $http.jsonp(moduleView+'id='+$scope.infaceModules[p].moduleID+'&userID=3&jsoncallback=JSON_CALLBACK'
                            ).success(function (modulData, header, config, status) {
                                $scope.childGetMouds[p].push(modulData);
                                console.log("aa"+p);
                                console.log($scope.childGetMouds[p]);
                            });
                        })(p);
                    }
                    if(p==$scope.infaceModules.length){
                        console.log("实际模块对象最终")
                        console.log($scope.childGetMouds);
                        childGetMouds=$scope.childGetMouds;
                    }


                    //切除banner对象，普通稿件数据
                    console.log("完整")
                    console.log(data)
                    var datas=data.list;
                    if(bannerCount){
                        // 新增 if($scope.bannerObj)
                        if($scope.bannerObj){
                            for(var i=0;i<$scope.bannerObj.length;i++){
                                for(var j=0;j<datas.length;j++){
                                    if(datas[j].fileId==$scope.bannerObj[i].fileId){
                                        datas.splice(j,1);

                                    }
                                }
                            }
                        }

                    }
                    //普通稿件切换banner对象后数据
                    if($scope.columnStyle!=221&&$scope.columnStyle!=225&&$scope.columnStyle!=203){
                        $scope.Hdata=datas; //所有数据中去除banner中对象
                        console.log("Hdata");
                        console.log($scope.Hdata);
                        //大于20条有加载更多功能
                         if($scope.Hdata.length+bannerCount>=20){
                        //加载更多页数设置为0
                        artiPageNum=0;
                        //显示加载更多按钮
                        $scope.loadMoreButtonOne = true;
                        $scope.noLoadMoreButton=false;
                        //最后一篇文章id号
                        $scope.lastArticlFileId=$scope.Hdata[$scope.Hdata.length-1].fileId;
                        // // 文章页数

                         }else{
                             $scope.noLoadMoreButton=true;
                             $scope.loadMoreButtonOne = false;
                         }
                     }
                    //直播切换banner对象后数据
                    if($scope.columnStyle==225){
                        $scope.Livedata=datas;
                        console.log("直播数据切换banner后")
                        console.log($scope.Livedata);
                        //加载更多页数设置为0
                        livePageNum=0;
                        if($scope.Livedata.length+bannerCount>=20){
                        $scope.lastLiveFileId=$scope.Livedata[$scope.Livedata.length-1].fileId;
                        //显示直播加载更多按钮
                            $scope.loadMoreButtonOne = true;
                            $scope.noLoadMoreButton = false;
                         }else{
                            $scope.noLoadMoreButton=true;
                            $scope.loadMoreButtonOne = false;
                        }
                    }
                    //视频切换banner对象后数据
                    if($scope.columnStyle==203){
                        vedioPageNum=0;
                        $scope.vedioData=datas;
                        console.log("视频id");
                        console.log($scope.vedioData);
                        //最后视频id
                         if($scope.vedioData.length+bannerCount>=20){
                        $scope.lastVedioFileId=$scope.vedioData[$scope.vedioData.length-1].fileId;
                        //显示直播加载更多按钮
                           $scope.loadMoreButtonOne = true;
                             $scope.noLoadMoreButton=false;
                        }else{
                             $scope.loadMoreButtonOne = false;
                             $scope.noLoadMoreButton=true;
                         }
                    }

                }).error(function (data, header, config, status) {
                });

                if($scope.columnStyle==221){
                    //活动列表数据
                    $http.jsonp(actDataUrl+'page=0&jsoncallback=JSON_CALLBACK'
                    ).success(function(data,header,config,status){
                        $scope.ActHdata=data.list;
                        console.log("活动data");
                        console.log($scope.ActHdata);
                        if($scope.ActHdata.length+bannerCount>=20){
                            //显示直播加载更多按钮
                            $scope.actPageNumb=1;
                            $scope.loadMoreButtonOne = true;
                            $scope.noLoadMoreButton=false;
                        }else{
                            $scope.noLoadMoreButton=true;
                            $scope.loadMoreButtonOne = false;
                        }
                    }).error(function(data,header,config,status){
                    });
                }



            }).error(function(data,header,config,status){
            });

            console.log('newSwipers');
            console.log(newSwipers);

            //loading提示
            $("#globalLoading").animate({
                opacity:'0'
            },500);

        };

        artiPageNum=0;
        //加载更多按钮
        $scope.loadMore = function (coluId,columnStyle) {
            //loading提示
            $("#globalLoading").css({
                opacity:'1'
            });
            artiPageNum++;
            console.log(artiPageNum);
            // 活动视频直播调用接口不同，要做判断
            if(columnStyle!=221&&columnStyle!=225&&columnStyle!=203){
                $http.jsonp(articalDataUrl+'columnId=' + coluId + '&page='+artiPageNum+'&lastFileId='+$scope.lastArticlFileId+'&jsoncallback=JSON_CALLBACK'
                ).success(function (data, header, config, status) {
                    $scope.lastArticlFileId = data.list[data.list.length-1].fileId;
                    console.log("普通稿件加载更多数据")
                    console.log(data)
                    $scope.Hdata=$scope.Hdata.concat(data.list);
                    if (data.list.length < 20) {
                        //     //没有更多，隐藏按钮
                        $scope.loadMoreButtonOne = false;
                        $scope.noLoadMoreButton=true;
                    }else{
                        $scope.loadMoreButtonOne = true;
                        $scope.noLoadMoreButton=false;
                    }

                }).error(function (data, header, config, status) {
                });
            }
            if (columnStyle==225){
                //直播列表
                livePageNum++;
                $http.jsonp(liveDataUrl+'columnId='+coluId+'&page='+livePageNum+'&lastFileId='+$scope.lastLiveFileId+'&jsoncallback=JSON_CALLBACK'
                ).success(function (data, header, config, status) {
                    $scope.Livedata = $scope.Livedata.concat(data.list);
                    console.log('直播加载更多数据dd');
                    console.log(data);
                    $scope.lastLiveFileId = data.list[data.list.length - 1].fileId;
                    if (data.list.length < 20) {
                        //     //没有更多，隐藏按钮
                        $scope.loadMoreButtonOne = false;
                        $scope.noLoadMoreButton=true;
                    }else{
                        $scope.loadMoreButtonOne = true;
                        $scope.noLoadMoreButton=false;
                    }
                }).error(function (data, header, config, status) {
                });
            }
            else if(columnStyle==203){
                //视频列表数据
                vedioPageNum++;
                $http.jsonp(vedioDataUrl+'columnId='+coluId+'&page='+vedioPageNum+'&lastFileId='+$scope.lastVedioFileId+'&jsoncallback=JSON_CALLBACK'
                ).success(function(data,header,config,status){
                    console.log("视频加载更多数据")
                    console.log(data)
                    $scope.vedioData = $scope.vedioData.concat(data.list);
                    $scope.lastVedioFileId = data.list[data.list.length - 1].fileId;
                    if (data.list.length < 20) {
                        //     //没有更多，隐藏按钮
                        $scope.loadMoreButtonOne = false;
                        $scope.noLoadMoreButton=true;
                    }else{
                        $scope.loadMoreButtonOne = true;
                        $scope.noLoadMoreButton=false;
                    }
                }).error(function(data,header,config,status){
                });
            }
            else if(columnStyle==221){
                //活动列表数据
                $http.jsonp(actDataUrl+'page='+$scope.actPageNumb+'&jsoncallback=JSON_CALLBACK'
                ).success(function(data,header,config,status){
                    console.log("活动加载更多数据")
                    console.log(data)
                    $scope.ActHdata = $scope.ActHdata.concat(data.list);
                    if (data.list.length<20) {
                        //     //没有更多，隐藏按钮
                        $scope.loadMoreButtonOne = false;
                        $scope.noLoadMoreButton=true;
                    }else{
                        $scope.loadMoreButtonOne = true;
                        $scope.noLoadMoreButton=false;
                    }
                    $scope.actPageNumb++;
                }).error(function(data,header,config,status){
                });
            }

            //loading提示
            $("#globalLoading").animate({
                opacity:'0'
            },500);

        };


      /*  //模态框body点击隐藏
        $scope.hideMode = function () {
            $('#myModal').modal('hide');
        }
        //模态框js-内容图片预览
        $scope.showMoCrenImges = '';
        $scope.showModelImg = function (curIndex, $event) {
            $scope.imgScalImg = [];
            $('#myModal').modal('show');
            $scope.showCurImg = angular.element($event.target);
            $scope.showCurImgUrl = $scope.showCurImg.context.currentSrc;
            var phtos = $scope.showCurImg.parent().parent().parent().find("img");
            for (var i = 0; i < phtos.length; i++) {
                $scope.imgScalImg.push(phtos[i].currentSrc);
            }
            $scope.showImgsList = angular.element(event.target).parent().parent().find('img');

            // $scope.showMoCrenImges= $scope.showImgsList[curIndex].currentSrc
        };

        // 直播详情图片预览
        $scope.showliveModelImg = function (currIndex, $event) {
            $scope.imgScalImg = [];
            $('#myModal').modal('show');
            $scope.showCurImg = angular.element($event.target);
            var phtos = $scope.showCurImg.parent().parent().parent().find("img");
            for (var i = 0; i < phtos.length; i++) {
                $scope.imgScalImg.push(phtos[i].currentSrc);
            }

        };
        // 视频列表图片预览
        $scope.showVedioListModelImg = function ($event) {
            $scope.imgScalImg = [];
            $('#myModal').modal('show');
            $scope.showCurImg = angular.element($event.target);
            var phtos = $scope.showCurImg.parent().find("img");
            $scope.imgScalImg.push(phtos[0].currentSrc);


        };
        // 活动图片预览
        $scope.showModelActImg = function ($event) {
            $scope.imgScalImg = [];
            $('#myModal').modal('show');
            $scope.showCurImg = angular.element($event.target);
            $scope.actImgUrl = angular.element($event.target).context.currentSrc;
            $scope.imgScalImg.push($scope.actImgUrl);
        };
*/

        //跳转回主页
        $scope.home = function () {
            $scope.chanNav(firstPageColumns);
            $location.path('/home', {cache: true}, {reload: true});
        }

        //频道回退按钮
        $scope.goBack = function () {
            $window.history.back();
        }

        //全局详情展开功能
        window.detailLaunch=function () {
            $(".detailConStyle").removeClass('detailsHidde');
            $('.DetailConMor').css("display","none");
        };

        // 点赞收藏初始图标
        $rootScope.detailAddPraseImag="static/13.png";
        $rootScope.detailAddStorImag="static/15.png";
        //点赞小图标
        $rootScope.detailAddPraseImagSmall="static/thub.png";
        $rootScope.detailAddStorImagSmall="static/18.png";

        $scope.hasMoreSearch=false;
        //全局搜索
       var searchStart=0,searchStartCount=20;
       $scope.serchAtr=function(){
           if($scope.showSerInput){
               if($("#artSearch").val()){
                   searchStart=0;
                   searchStartCount=20
                   //搜索数据artSearVal
                   $location.path('/search');
                   console.log("关键字")
                   $("#artSearch").focus();
                   console.log($("#artSearch").val())
                   $scope.artSearVal=$("#artSearch").val();
                   $http.jsonp(articalSearch+'&key='+$scope.artSearVal+'&start=0&count=20&jsoncallback=JSON_CALLBACK'
                   ).success(function(data,header,config,status){
                       console.log("搜索结果");
                       console.log(data);
                       $scope.serchHdata=data;
                       //大于20条可以显示加载更多按钮
                       if(data.length==20){
                           $scope.hasMoreSearch=true;
                       }
                       searchArr=$scope.serchHdata;
                       $scope.showSerInput=false;
                       $("#artSearch").val("");

                   }).error(function(data,header,config,status){
                       console.log("错误信息");
                       console.log(data)
                   });
               }else{
                   alert("请输入需要搜索的内容");
                   $scope.showSerInput=false;
               }

           }else{

               $scope.showSerInput=true;
           }

       }
       //全局搜索加载更多
        $scope.serchAtrLoadMore=function(){
            searchStart++;
            console.log("搜索更多页数")
            console.log(searchStart)
            searchStartCount=(searchStart+1)*20;
            $http.jsonp(articalSearch+'&key='+$scope.artSearVal+'&start='+searchStart+'&count='+searchStartCount+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("搜索加载更多结果");
                console.log(data);
                $scope.serchHdata=$scope.serchHdata.concat(data);

            }).error(function(data,header,config,status){
                console.log("错误信息");
                console.log(data)
            });

        };

        ////登录模态框
        //$scope.showModal = function () {
        //    $('#myModal').modal('show');
        //}

        //全局样式，没有评论的情况下需要添加的颜色
        $rootScope.changeComStyle=function(){
            if(commentStyle=='blue'){
                $('.detailActComm span').css({borderLeft:"2px solid #2E97E9",color:'#2E97E9'});
                $('.commt_con a').each(function () {
                    console.log($(this))
                    $(this).css({color:'#2E97E9'})
                })
                $('#commt_com_repla a').each(function () {
                    console.log($(this))
                    $(this).css({color:'#2E97E9'})
                })
                $('.com-childen-more').each(function () {
                    console.log('tang')
                    console.log($(this))
                    $(this).css({color:'#2E97E9'})
                })
                $('.comm_heade_btn button').css({background:'#2E97E9'});
                $('.reportComText button').css({background:'#2E97E9'});
                $('.reportComTextReply button').css({background:'#2E97E9'});
                $('.comBtnTwo').css({border: '1px solid #2E97E9',color:'#2E97E9'})
                $('#commeInputs').css({border: '1px solid #2E97E9'})
                $('.commet_count_num').css({color:'#2E97E9'})
                $('.comm_hot_tit a').css({color:'#2E97E9'})
            }else if(commentStyle=='red'){

                $('.detailActComm span').css({borderLeft:"2px solid red",color:'red'});
                $('.commt_con a').each(function () {
                    console.log($(this))
                    $(this).css({color:'red'})
                })
                $('#commt_com_repla a').each(function () {
                    console.log($(this))
                    $(this).css({color:'red'})
                })
                $('.com-childen-more').each(function () {
                    console.log($(this))
                    $(this).css({color:'red'})
                })
                $('.comm_heade_btn button').css({background:'red'});
                $('.reportComText button').css({background:'red'});
                $('.reportComTextReply button').css({background:'red'});
                $('.comBtnTwo').css({border: '1px solid red',color:'red'})
                $('#commeInputs').css({border: '1px solid red'})
                $('.commet_count_num').css({color:'red'})
                $('.comm_hot_tit a').css({color:'red'})
            }else if(commentStyle=='orange'){
                $('.detailActComm span').css({borderLeft:"2px solid orange",color:'orange'});
                $('.commt_con a').each(function () {
                    console.log($(this))
                    $(this).css({color:'orange'})
                })
                $('#commt_com_repla a').each(function () {
                    console.log($(this))
                    $(this).css({color:'orange'})
                })
                $('.com-childen-more').each(function () {
                    console.log($(this))
                    $(this).css({color:'orange'})
                })
                $('.comm_heade_btn button').css({background:'orange'});
                $('.reportComText button').css({background:'orange'});
                $('.reportComTextReply button').css({background:'orange'});
                $('.comBtnTwo').css({border: '1px solid orange',color:'orange'})
                $('#commeInputs').css({border: '1px solid orange'})
                $('.commet_count_num').css({color:'orange'})
                $('.comm_hot_tit a').css({color:'orange'})
            }else if(commentStyle=='black'){
                $('.detailActComm span').css({borderLeft:"2px solid black",color:'black'});
                $('.commt_con a').each(function () {
                    console.log($(this))
                    $(this).css({color:'black'})
                })
                $('#commt_com_repla a').each(function () {
                    console.log($(this))
                    $(this).css({color:'black'})
                })
                $('.com-childen-more').each(function () {
                    console.log($(this))
                    $(this).css({color:'black'})
                })
                $('.comm_heade_btn button').css({background:'black'});
                $('.reportComText button').css({background:'black'});
                $('.reportComTextReply button').css({background:'black'});
                $('.comBtnTwo').css({border: '1px solid black',color:'black'})
                $('#commeInputs').css({border: '1px solid black'})
                $('.commet_count_num').css({color:'black'})
                $('.comm_hot_tit a').css({color:'black'})
            }else if(commentStyle=='green'){
                $('.detailActComm span').css({borderLeft:"2px solid #5ECE5E",color:'#5ECE5E'});
                $('.commt_con a').each(function () {
                    console.log($(this))
                    $(this).css({color:'#5ECE5E'})
                })
                $('#commt_com_repla a').each(function () {
                    console.log($(this))
                    $(this).css({color:'#5ECE5E'})
                })
                $('.com-childen-more').each(function () {
                    console.log($(this))
                    $(this).css({color:'#5ECE5E'})
                });
                $('.comm_heade_btn button').css({background:'#5ECE5E'});
                $('.reportComText button').css({background:'#5ECE5E'});
                $('.reportComTextReply button').css({background:'#5ECE5E'});
                $('.comBtnTwo').css({border: '1px solid #5ECE5E',color:'#5ECE5E'})
                $('#commeInputs').css({border: '1px solid #5ECE5E'})
                $('.commet_count_num').css({color:'#5ECE5E'})
                $('.comm_hot_tit a').css({color:'#5ECE5E'})
            }else if(commentStyle=='gray'){
                $('.detailActComm span').css({borderLeft:"2px solid gray",color:'gray'});
                $('.commt_con a').each(function () {
                    console.log($(this))
                    $(this).css({color:'gray'})
                })
                $('#commt_com_repla a').each(function () {
                    console.log($(this))
                    $(this).css({color:'gray'})
                })
                $('.com-childen-more').each(function () {
                    console.log($(this))
                    $(this).css({color:'gray'})
                })
                $('.comm_heade_btn button').css({background:'gray'});
                $('.reportComText button').css({background:'gray'});
                $('.reportComTextReply button').css({background:'gray'});
                $('.comBtnTwo').css({border: '1px solid gray',color:'gray'})
                $('#commeInputs').css({border: '1px solid gray'})
                $('.commet_count_num').css({color:'gray'})
                $('.comm_hot_tit a').css({color:'gray'})
            }

        }
}]);
/**
 * 指令
 * */
//时间显示样式
app.filter('fomatTime', function () {
    return function (valueTime) {
        var oldData=new Date(valueTime.replace(/-/g, "/"));
        var newData=new Date();
        var diffTime=Math.abs(oldData - new Date());
        if(diffTime>7*24*3600*1000){
            var dayNum=valueTime.slice(5,16);
            return dayNum;

        }else if(diffTime<7*24*3600*1000&&diffTime>24*3600*1000){
            // console.log("一周之内");
            var time =newData.getTime()-oldData.getTime();
            var dayNum=Math.floor(time/(24*60*60*1000));
            return dayNum+"天前";

        }else if(diffTime<24*3600*1000&&diffTime>3600*1000){
            // console.log("一天之内");
            var time =newData.getTime()-oldData.getTime();
            var dayNum=Math.floor(time/(60*60*1000));
            return dayNum+"小时前";

        }else if(diffTime<3600*1000&&diffTime>0){
            // console.log("一小时之内");
            var time =newData.getTime()-oldData.getTime();
            var dayNum=Math.floor(time/(60*1000));
            return dayNum+"分钟前";

        }
        /* else if(diffTime<60*1000&&diffTime>0){
         // console.log("几分钟之内");
         var time =newData.getTime()-oldData.getTime();
         var dayNum=Math.floor(time/(60*1000));
         return dayNum+"分钟前";

         }*/
    };
});

//主播视频时长转换
app.filter('durationTime', function () {
    return function (value) {
        if(value){
            var theTime = parseInt(value);// 秒
            var theTime1 = 0;// 分
            var theTime2 = 0;// 小时
            if(theTime > 60) {
                theTime1 = parseInt(theTime/60);
                theTime = parseInt(theTime%60);
                if(theTime1 > 60) {
                    theTime2 = parseInt(theTime1/60);
                    theTime1 = parseInt(theTime1%60);
                }
            }

            var result = ""+parseInt(theTime)+"";

            if(result >= 0 && result <= 9){
                result = "0"+ result;
            }else{
                result = ""+ result;
            }

            if(theTime1 > 0) {

                if(parseInt(theTime1)>= 1 && parseInt(theTime1)<=9){
                    result = "0"+parseInt(theTime1)+":"+result;
                }else{
                    result = ""+parseInt(theTime1)+":"+result;
                }

            }else{
                result = "00" + ":" + result;
            }
            if(theTime2 > 0) {
                if(parseInt(theTime2) > 0){
                    if(parseInt(theTime2)>= 1 && parseInt(theTime2)<=9){
                        result = "0"+parseInt(theTime2)+":"+result;
                    }else{
                        result = ""+parseInt(theTime2)+":"+result;
                    }

                }

            }
            console.log(result);
            return result;
        }else{
            var result = "00"+ ":" + "00";
            return result;
        }

    }
});

//活动详情，年月时分
app.filter('actHour', function () {
    return function (value) {
        if(value){
            var dayNum=value.slice(5,16);
            return dayNum;
        }
    };
});
//保留时分秒
app.filter('cutHour', function () {
    return function (value) {
        var indexSpac=value.indexOf(" ");
        var lastHourString=value.substring(indexSpac);
        return lastHourString;
    };
});
//保留年月日
app.filter('cutDay', function () {
    return function (value) {
        if(value){
            var indexSpac=value.indexOf(" ");
            var lastHourString=value.substring(0,indexSpac);
            return lastHourString;
        }
    };
});
//详情时间，到秒
app.filter('cutSecond', function () {
    return function (value) {
        if(value){
            var indexSpac=value.indexOf(":");
            var lastHourString=value.substring(0,indexSpac+3);
            return lastHourString;
        }
    };
});
//直播详情判断mp3.mp4类型
app.filter('urlType', function () {
    return function (value) {
        var urlTypes=value.slice(-3)
        return urlTypes;
    };
});
app.directive('repeatFinish',function(){
    return {
        link: function(scope,element,attr){
            if(scope.$last == true){
                $("#homeNavChannelTextUl li").eq(lightIndex).css({background:"#fc9105"});
                $("#homeNavChannelTextUl li").eq(lightIndex).find('a').css({color:"#ffffff",fontSize:'0.18rem'});
                $(".homeNavTextUl li").eq(lightIndex).css({color:"#000",fontSize:'0.18rem',background:"#fc9105"});

            }
        }
    }
})

//评论换肤
app.directive('commRepeatFinish',function(){
    return {
        link: function(scope,element,attr){
            if(scope.$last == true){
                console.log('commt ng-repeat执行完毕')
                setTimeout(function(){
                    if(commentStyle=='blue'){
                        $('.detailActComm span').css({borderLeft:"2px solid #2E97E9",color:'#2E97E9'});
                        $('.commt_con a').each(function () {
                            $(this).css({color:'#2E97E9'})
                        })
                        $('#commt_com_repla a').each(function () {
                            console.log($(this))
                            $(this).css({color:'#2E97E9'})
                        })
                        $('.com-childen-more').each(function () {
                            console.log('tang')
                            console.log($(this))
                            $(this).css({color:'#2E97E9'})
                        })
                        $('.comm_heade_btn button').css({background:'#2E97E9'});
                        $('.reportComText button').css({background:'#2E97E9'});
                        $('.reportComTextReply button').css({background:'#2E97E9'});
                        $('.comBtnTwo').css({border: '1px solid #2E97E9',color:'#2E97E9'})
                        $('#commeInputs').css({border: '1px solid #2E97E9'})
                        $('.commet_count_num').css({color:'#2E97E9'})
                        $('.comm_hot_tit a').css({color:'#2E97E9'})
                    }else if(commentStyle=='red'){

                        $('.detailActComm span').css({borderLeft:"2px solid red",color:'red'});
                        $('.commt_con a').each(function () {
                            console.log($(this))
                            $(this).css({color:'red'})
                        })
                        $('#commt_com_repla a').each(function () {
                            console.log($(this))
                            $(this).css({color:'red'})
                        })
                        $('.com-childen-more').each(function () {
                            console.log($(this))
                            $(this).css({color:'red'})
                        })
                        $('.comm_heade_btn button').css({background:'red'});
                        $('.reportComText button').css({background:'red'});
                        $('.reportComTextReply button').css({background:'red'});
                        $('.comBtnTwo').css({border: '1px solid red',color:'red'})
                        $('#commeInputs').css({border: '1px solid red'})
                        $('.commet_count_num').css({color:'red'})
                        $('.comm_hot_tit a').css({color:'red'})
                    }else if(commentStyle=='orange'){
                        $('.detailActComm span').css({borderLeft:"2px solid orange",color:'orange'});
                        $('.commt_con a').each(function () {
                            console.log($(this))
                            $(this).css({color:'orange'})
                        })
                        $('#commt_com_repla a').each(function () {
                            console.log($(this))
                            $(this).css({color:'orange'})
                        })
                        $('.com-childen-more').each(function () {
                            console.log($(this))
                            $(this).css({color:'orange'})
                        })
                        $('.comm_heade_btn button').css({background:'orange'});
                        $('.reportComText button').css({background:'orange'});
                        $('.reportComTextReply button').css({background:'orange'});
                        $('.comBtnTwo').css({border: '1px solid orange',color:'orange'})
                        $('#commeInputs').css({border: '1px solid orange'})
                        $('.commet_count_num').css({color:'orange'})
                        $('.comm_hot_tit a').css({color:'orange'})
                    }else if(commentStyle=='black'){
                        $('.detailActComm span').css({borderLeft:"2px solid black",color:'black'});
                        $('.commt_con a').each(function () {
                            console.log($(this))
                            $(this).css({color:'black'})
                        })
                        $('#commt_com_repla a').each(function () {
                            console.log($(this))
                            $(this).css({color:'black'})
                        })
                        $('.com-childen-more').each(function () {
                            console.log($(this))
                            $(this).css({color:'black'})
                        })
                        $('.comm_heade_btn button').css({background:'black'});
                        $('.reportComText button').css({background:'black'});
                        $('.reportComTextReply button').css({background:'black'});
                        $('.comBtnTwo').css({border: '1px solid black',color:'black'})
                        $('#commeInputs').css({border: '1px solid black'})
                        $('.commet_count_num').css({color:'black'})
                        $('.comm_hot_tit a').css({color:'black'})
                    }else if(commentStyle=='green'){
                        $('.detailActComm span').css({borderLeft:"2px solid #5ECE5E",color:'#5ECE5E'});
                        $('.commt_con a').each(function () {
                            console.log($(this))
                            $(this).css({color:'#5ECE5E'})
                        })
                        $('#commt_com_repla a').each(function () {
                            console.log($(this))
                            $(this).css({color:'#5ECE5E'})
                        })
                        $('.com-childen-more').each(function () {
                            console.log($(this))
                            $(this).css({color:'#5ECE5E'})
                        })
                        $('.comm_heade_btn button').css({background:'#5ECE5E'});
                        $('.reportComText button').css({background:'#5ECE5E'});
                        $('.reportComTextReply button').css({background:'#5ECE5E'});
                        $('.comBtnTwo').css({border: '1px solid #5ECE5E',color:'#5ECE5E'})
                        $('#commeInputs').css({border: '1px solid #5ECE5E'})
                        $('.commet_count_num').css({color:'#5ECE5E'})
                        $('.comm_hot_tit a').css({color:'#5ECE5E'})
                    }else if(commentStyle=='gray'){
                        $('.detailActComm span').css({borderLeft:"2px solid gray",color:'gray'});
                        $('.commt_con a').each(function () {
                            console.log($(this))
                            $(this).css({color:'gray'})
                        })
                        $('#commt_com_repla a').each(function () {
                            console.log($(this))
                            $(this).css({color:'gray'})
                        })
                        $('.com-childen-more').each(function () {
                            console.log($(this))
                            $(this).css({color:'gray'})
                        })
                        $('.comm_heade_btn button').css({background:'gray'});
                        $('.reportComTextReply button').css({background:'gray'});
                        $('.reportComText button').css({background:'gray'});
                        $('.comBtnTwo').css({border: '1px solid gray',color:'gray'})
                        $('#commeInputs').css({border: '1px solid gray'})
                        $('.commet_count_num').css({color:'gray'})
                        $('.comm_hot_tit a').css({color:'gray'})
                    }
                },500)
            }
        }
    }

});








